<script setup>
import { watchEffect } from 'vue'
import { useRoute } from 'vue-router'
import { useUserStore } from '@/stores/user.js'

const userStore = useUserStore()
const route = useRoute()

watchEffect(() => {
  const routeToken = route.query.token  // ✅ 改名，避免和 ref 混淆
  if (routeToken) {
    userStore.setToken(routeToken)    // ✅ 正确赋值
    window.history.replaceState({}, '', window.location.pathname)  // 清除 token 参数
  }
})
</script>


<template>

  <!-- 路由出口 -->
  <RouterView />
</template>

<style scoped lang="scss">

</style>
